<?php
    App::import('Model', 'Event');


    class EventTestCase extends CakeTestCase {
        var $fixtures = array('app.event', 'app.family', 'app.events_family', 'app.person',
                              'app.families_person');

		function testGetEventFamilyNames() {
			$this->Event =& ClassRegistry::init('Event');
			
			$result = $this->Event->getEventFamilyNames(1);
			$expected = array(0 => 'testFamily1');
			$this->assertEqual($result, $expected);
		}
		
		function testGetEventFamilyIDs() {
			$this->Event =& ClassRegistry::init('Event');
			
			$result = $this->Event->getEventFamilyIDs(1);
			$expected = array(0 => 1);
			$this->assertEqual($result, $expected);
		}


        function testNextPage() {
            $this->Event =& ClassRegistry::init('Event');
            
            $result = $this->Event->getNextPage(0,1,1);
            $expected = 1;
            $this->assertEqual($result, $expected);
            
            $result = $this->Event->getNextPage(5,1,4);
            $expected = 2;
            $this->assertEqual($result, $expected);

            $result = $this->Event->getNextPage(8,0,7);
            $expected = 1;
            $this->assertEqual($result, $expected);
            
            $result = $this->Event->getNextPage(16,3,4);
            $expected = 4;
            $this->assertEqual($result, $expected);
        }
        
        function testPreviousPage() {
            $this->Event =& ClassRegistry::init('Event');
            
            $result = $this->Event->getPreviousPage(0,1,1);
            $expected = 1;
            $this->assertEqual($result, $expected);
            
            $result = $this->Event->getPreviousPage(5,0,1);
            $expected = 1;
            $this->assertEqual($result, $expected);
            
            $result = $this->Event->getPreviousPage(5,2,1);
            $expected = 1;
            $this->assertEqual($result, $expected); 

			$result = $this->Event->getPreviousPage(4,5,4);
			$expected = 1;
			$this->assertEqual($result, $expected);                     
        }

		function testHostFromID() {
			$this->Event =& ClassRegistry::init('Event');
			
			$result = $this->Event->getHostFromID(1);
			$expected = 1;
			$this->assertEqual($result, $expected);
		}
    
        function testGetEvents() {
            $this->Event =& ClassRegistry::init('Event');
            
            $result = $this->Event->getEventFromID(1);
            $expected = array(
                'id' => 1,
                'family_id' => 1,
                'name' => 'event1',
                'eventdate' => '2011-02-21',
                'created' => '2010-10-10 10:10:10',
                'modified' => '2010-10-10 10:10:10'
            );
            $this->assertEqual($result, $expected);
        }
    
    }
